import { Component } from "@angular/core";
import { NgForm } from "@angular/forms";
interface listItem {
  listname: string;
  status?: boolean;
  id?: number;
}
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
export class AppComponent {
  username: string = "";
  public list: any = [
    {
      listname: "张三",
      status: false,
      id: 1,
    },
    {
      listname: "李四",
      status: false,
      id: 2,
    },
  ];
  onSubmit() {
    if (this.username === "") {
      return;
    }
    var obj: listItem = {
      listname: this.username,
      status: false,
      id: this.list.length + 1,
    };

    this.list.push(obj);

    console.log("添加数据");
  }
  deleteItem(e: number) {
    this.list.splice(e, 1);
  }
}
